﻿/// <reference path="../../../jquery-2.1.0.js" />
/// <reference path="../../../jasime/jasmine.js" />
/// <reference path="../../../jasime/jasmine-jquery.js" />
/// <reference path="../../../angular.js" />
/// <reference path="../../../angular-mocks.js" />
/// <reference path="../../../angular-bootstrap.js" />
/// <reference path="../../../angular-resource.js" />
/// <reference path="../../../angular-mocks.js" />
/// <reference path="../../../ui-bootstrap-0.7.0.js" />
/// <reference path="../../../angular-cookies.js" /> 
/// <reference path="../../../toastr.js" />
/// <reference path="../../../ui.select2.js" />

/// <reference path="../../../ngRoute.js" />
/// <reference path="../../../geocoder.js" />
/// <reference path="../../../underscore.js" />
/// <reference path="../../../angular-underscore.js" />
/// <reference path="../../../datepicker.js" />

/// <reference path="../../../app/app.js" />
/// <reference path="../../../app/directives.js" />
/// <reference path="../../../app/filters.js" />
/// <reference path="../../../app/services.js" />
/// <reference path="../../../app/controllers.js" />

// test/unit/controllers/spec.js
//
var LookupData = [

{ "Title": "Male", "Color": null, "LookupTypeID": 7, "LookupID": 6, "Discriminator": "Gender" },
{ "Title": "Femaile", "Color": null, "LookupTypeID": 7, "LookupID": 7, "Discriminator": "Gender" },
{ "Title": "Other", "Color": null, "LookupTypeID": 7, "LookupID": 8, "Discriminator": "Gender" }
];

describe("Unit: Testing Controllers", function () {

    var ctrl, ctrlScope;

    beforeEach(inject(function ($controller, $rootScope) {

        ctrlScope = $rootScope.$new();
        ctrl = $controller(homeCtrl, { $rootScope: ctrlScope });
    }));


    it('should have a homeCntrl controller', function () {
        expect(ctrlScope).not.toBeUndefined();
        expect(ctrl).not.toBeUndefined();
    });

    ctrl = null;
    ctrlScope = null;

    beforeEach(inject(function ($controller, $rootScope) {

        ctrlScope = $rootScope.$new();
        ctrl = $controller(aboutCtrl, { $scope: ctrlScope });
    }));

    it('should have a aboutCtrl controller', function () {
        expect(ctrlScope).not.toBeUndefined();
        expect(ctrl).not.toBeUndefined();
    });



});

describe('Team Controller', function () {

    var scope, controller, root, logger, myService;
    var log = angular.mock.$LogProvider();
    beforeEach(module('app.services'));

    beforeEach(inject(function ($controller, $rootScope) {

        var $injector = angular.injector();
        var TeamServicesMock = { GetTeams: function () { return null } }; //service = $injector.get('configService');
        var $injector = angular.injector(['app.services']);
        //myService = $injector.get('TeamServices');

        ////Creating spies for functions of Admin service
        //spyOn(myService, 'GetTeams').andReturn(null);
        //spyOn(myService, 'GetTeam').andCallThrough();
        //spyOn(myService, 'PostTeam').andCallThrough();
        //spyOn(myService, 'DeleteTeam').andCallThrough();

        scope = $rootScope.$new();
        controller = $controller("teamCtrl", {
            $rootScope: scope,
            $scope: scope, TeamServices: TeamServicesMock, logger: log
        });
    }));
    it('should have a teamCtrl controller', function () {
        expect(controller).not.toBeUndefined();
    });
    //it('should have a teams', function () {
    //    expect(scope.teams).not.toBeUndefined();
    //});

});

describe('TeamDetail Controller', function () {

    var scope, controller, root, logger;
    var log = angular.mock.$LogProvider();
    beforeEach(module('app.services'));

    beforeEach(inject(function ($controller, $rootScope) {

        var $injector = angular.injector();
        //routeparams

        var TeamServicesMock = { GetTeam: function () { return null } };
        var AdminServicesMock = { GetByDesc: function () { return null } };
        scope = $rootScope.$new();
        controller = $controller("teamDetailCtrl", {
            $rootScope: scope,
            $scope: scope,
            $routeParams: {
                id: 1
            },
            TeamServices: TeamServicesMock,
            AdminServices: AdminServicesMock,
            logger: log
        });
    }));
    it('should have a teamDetailCtrl controller', function () {
        expect(controller).not.toBeUndefined();
    });
    //it('should have a team', function () {
    //    expect(scope.team).not.toBeUndefined();
    //});

});

describe('Admin Controller', function () {
    var scope, controller, root, logger, myService, storedItems;
    var log = angular.mock.$LogProvider();
    beforeEach(module('app.services'));

    beforeEach(inject(function ($controller, $rootScope) {

      
        var $injector = angular.injector(['app.services']);
      //  myService = $injector.get('AdminServices');
        //Storing test data to an object
        storedItems = LookupData;

        //Creating spies for functions of Admin service
       // spyOn(myService, 'GetByDesc').andReturn(storedItems);
        //spyOn(myService, 'Get').andCallThrough();
        //spyOn(myService, 'Post').andCallThrough();
        //spyOn(myService, 'Delete').andCallThrough();
        var AdminServicesMock = { GetByDesc: function () { return null } };
        scope = $rootScope.$new();
        controller = $controller("adminCtrl", {
            $rootScope: scope,
            $scope: scope, $routeParams: {
                id: "Gender"
            }, AdminServices: AdminServicesMock, logger: log
        });

     
    }));

    it('should have a adminCtrl controller', function () {
        expect(controller).not.toBeUndefined();
    });
    it('should have a admin list', function () {
        expect(scope.admins).not.toBeUndefined();
    });
    //it('should have a admin list', function () {
    //    expect(AdminServicesMock.GetByDesc).toHaveBeenCalled();
    //});



});



describe('Incident Controller', function () {

    var scope, controller, root, logger;
    var log = angular.mock.$LogProvider();
    beforeEach(module('app.services'));

    beforeEach(inject(function ($controller, $rootScope) {

        var $injector = angular.injector();
        var IncidentServices = { GetIncidents: function () { return null } };
        var $injector = angular.injector(['app.services']);
        scope = $rootScope.$new();
        controller = $controller("incidentCtrl", {
            $rootScope: scope,
            $scope: scope,
            IncidentServices: IncidentServices,
            logger: log
        });
    }));
    it('should have a incidentCtrl controller', function () {
        expect(controller).not.toBeUndefined();
    });
    //it('should have a team', function () {
    //    expect(scope.team).not.toBeUndefined();
    //});

});


describe('incidentDetail Controller', function () {

    var scope, controller, root, logger;
    var log = angular.mock.$LogProvider();
    beforeEach(module('app.services'));

    beforeEach(inject(function ($controller, $rootScope) {

        var $injector = angular.injector();
        //routeparams

        var TeamServicesMock = { GetTeam: function () { return null } };
        var IncidentServicesMock = { GetIncident: function () { return null } };
        var LocationServicesMock = { DeleteLocation: function () { return null } };

        scope = $rootScope.$new();
        controller = $controller("incidentDetailCtrl", {
            $rootScope: scope,
            $scope: scope,
            $routeParams: {
                id: 1
            },
            TeamServices: TeamServicesMock,
            IncidentServices: IncidentServicesMock,
            LocationServices: LocationServicesMock,
            logger: log
        });
    }));
    it('should have a incidentDetailCtrl controller', function () {
        expect(controller).not.toBeUndefined();
    });
    //it('should have a team', function () {
    //    expect(scope.team).not.toBeUndefined();
    //});

});



describe('locationDetail Controller', function () {

    var scope, controller, root, logger;
    var log = angular.mock.$LogProvider();
    beforeEach(module('app.services'));

    beforeEach(inject(function ($controller, $rootScope) {

        var $injector = angular.injector();
        //routeparams

        var AdminServicesMock = { GetByDesc: function () { return null } };
       
        var LocationServicesMock = { GetLocation: function () { return null } };

        scope = $rootScope.$new();
        controller = $controller("locationDetailCtrl", {
            $rootScope: scope,
            $scope: scope,
            $routeParams: {
                id: 1
            },
                     
            LocationServices: LocationServicesMock,
            AdminServices: AdminServicesMock,
            logger: log
        });
    }));
    it('should have a locationDetailCtrl controller', function () {
        expect(controller).not.toBeUndefined();
    });
    //it('should have a team', function () {
    //    expect(scope.team).not.toBeUndefined();
    //});

});




describe('victim Controller', function () {

    var scope, controller, root, logger;
    var log = angular.mock.$LogProvider();
    beforeEach(module('app.services'));

    beforeEach(inject(function ($controller, $rootScope) {

        var $injector = angular.injector();
        //routeparams

        var AdminServicesMock = { GetByDesc: function () { return null } };

        var VictimServicesMock = { GetVictims: function () { return null } };

        scope = $rootScope.$new();
        controller = $controller("victimsCtrl", {
            $rootScope: scope,
            $scope: scope,
            $routeParams: {
                id: 1
            },

            VictimServices: VictimServicesMock,
            AdminServices: AdminServicesMock,
            logger: log
        });
    }));
    it('should have a victimsCtrl controller', function () {
        expect(controller).not.toBeUndefined();
    });
    //it('should have a team', function () {
    //    expect(scope.team).not.toBeUndefined();
    //});

});
